package com.sxj.corejava.code08_常用类.泛型;

/**
 * @author 石小俊
 * @date 2024年04月18日 20:21
 */
public class Person implements CompareInterface<Person>{

    private int age;
    private String name;

    public Person(int age, String name) {
        this.age = age;
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public int compareTo(Person person) {
        if(this.getAge() > person.getAge()){
            return 1;
        } else if(this.getAge() == person.getAge()){
            return 0;
        } else{
            return -1;
        }
    }
}
